<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
  xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
  layout:decorator="layout">
  <head>
    <title>接口文档</title>
    <script type="text/javascript">
    	$(function(){
    		$("tr[name='treeParam']").each(function(i,v){
    			$(v).attr("data-tt-parent-id", $(v).attr("data"));
    			$(v).attr("data-tt-id", $(v).attr("id"));
    		});
    		
    		
    		$('.table-son').each(function(i,v){
    			$(v).find("tr[name='treeParam']").each(function(i2,v2){
    				var parentId = $(v2).attr("data-tt-id");
    				$(v2).after($(v).find("tr[data-tt-parent-id='"+parentId+"']"));
    			});
    		});
    		
    		$('.table-son').treetable({
    		    theme:'vsStyle',
    		    expandLevel : 10,
    		    column:0,
    		    onSelect : function($treeTable, id) {
    		        window.console;
    		    }
    		});
    		
    		
    	});
	    
    </script>
  </head>
  <body>
    <div class="body" layout:fragment="content" style="text-align: center;">
    	<div class="doc-container">
    		
    		
    		<div class="ml-container">
    			<div class="ml-block" th:each="model : ${modelList}">
    				<h2 class="ml-title" th:text="${model.name}"></h2>
    				<div class="ml-api-block">
    					<div class="ml-api" th:each="api,obj : ${model.apis}">
    						<span th:text="${'('+obj.count+')'}"></span><a class="ml-api-title" th:href="${'#api_'+api.id}" th:text="${api.name}"></a>
    					</div>
    				</div>
    			</div>
    		</div>
    		
    		<div class="model-container">
    			<div class="model-block" th:each="model : ${modelList}">
	    			<h3 class="model-title" ><span th:text="${model.name}"></span></h3>
	    			<p class="model-desc" th:text="${model.description}"></p>
	    			
	    			<div class="api-container">
	    				<div class="api-block" th:each="api : ${model.apis}" th:id="${'api_'+api.id}">
	    					<div class="table-cont doc-table">
		    					<table border="0" cellspacing="0" cellpadding="0">
			                        <tbody>
			                        	<tr class="table-td-first">
			                        		<td><span class="table-input">接口名称</span></td>
			                        		<td><span class="table-input" th:text="${api.name}"></span></td>
			                        	</tr>
			                        	<tr class="table-td-first">
			                        		<td><span class="table-input">接口地址</span></td>
			                        		<td><span class="table-input" th:text="${sys.name+api.url}"></span></td>
			                        	</tr>
			                        	<tr>
			                        		<td><span class="table-input">请求方式</span></td>
			                        		<td><span class="table-input" th:text="${api.type}"></span></td>
			                        	</tr>
			                        	<tr>
			                        		<td><span class="table-input">接口说明</span></td>
			                        		<td><span class="table-input" th:text="${api.description}"></span></td>
			                        	</tr>
			                        	<tr>
			                        		<td colspan="2"></td>
			                        	</tr>
			                        	<tr th:unless="${api.getParams.empty}">
			                        		<td class="table-td-first"><span class="table-input">请求参数</span></td>
			                        		<td style="border: 0px;">
			                        			<table class="table-son">
			                        				<thead>
			                                            <tr>
			                                                <th width="200">字段</th>
			                                                <th>说明</th>
			                                            </tr>
			                                        </thead>
			                        				<tbody>
			                        					<tr th:each="param : ${api.getParams}" th:id="${param.id}" name="treeParam" th:data="${param.parentId}">
						                                    <td><span class="table-input table-input-label" th:text="${(param.name==null?'':param.name)+(param.type.toString()=='LIST'?' [...]':'')+(param.type.toString()=='MAP'?' {...}':'')}" ></span></td>
						                                    <td><span class="table-input"><pre th:text="${param.description}"></pre></span></td>
														</tr>
			                        				</tbody>
			                        			</table>
			                        		</td>
			                        	</tr>
			                        	
										
										<tr th:unless="${api.bodyParams.empty}">
			                        		<td class="table-td-first"><span class="table-input">请求BODY</span></td>
			                        		<td style="border: 0px;">
			                        			<table class="table-son">
			                        				<thead>
			                                            <tr>
			                                                <th width="200">字段</th>
			                                                <th>说明</th>
			                                            </tr>
			                                        </thead>
			                        				<tbody>
			                        					<tr th:each="param : ${api.bodyParams}" th:id="${param.id}" name="treeParam" th:data="${param.parentId}">
						                                    <td><span class="table-input table-input-label" th:text="${(param.name==null?'':param.name)+(param.type.toString()=='LIST'?' [...]':'')+(param.type.toString()=='MAP'?' {...}':'')}" ></span></td>
						                                    <td><span class="table-input"><pre th:text="${param.description}"></pre></span></td>
														</tr>
			                        				</tbody>
			                        			</table>
			                        		</td>
			                        	</tr>
			                        	
										
										<tr>
			                        		<td class="table-td-first"><span class="table-input">返回字段</span></td>
			                        		<td style="border: 0px;">
			                        			<table class="table-son">
			                        				<thead>
			                                            <tr>
			                                                <th width="200">字段</th>
			                                                <th>说明</th>
			                                            </tr>
			                                        </thead>
			                        				<tbody>
			                        					<tr th:each="param : ${api.ress}" th:id="${param.id}" name="treeParam" th:data="${param.parentId}">
						                                    <td><span class="table-input table-input-label" th:text="${(param.name==null?'':param.name)+(param.type.toString()=='LIST'?' [...]':'')+(param.type.toString()=='MAP'?' {...}':'')}" ></span></td>
						                                    <td><span class="table-input"><pre th:text="${param.description}"></pre></span></td>
														</tr>
			                        				</tbody>
			                        			</table>
			                        			
			                        		</td>
			                        	</tr>
			                        	
									</tbody>
								</table>
							</div>
	    				</div>
	    			</div>
    			</div>
    		</div>
    	</div>
    </div>
  </body>
</html>